package com.sell.sell.utils;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class ResultMsgUtil {
    /**
     * result : success
     * resultCode : 200  404  500
     * resultMsg : 成功   失败   为啥~
     * total : 0   数量
     * list :
     * map : 同上
     * data : 数据
     */
    private String result;
    private Integer resultCode;
    private String resultMsg;
    private Object data;
    public ResultMsgUtil() {
        this.result = "SUCCESS";
        this.resultCode = 0;
    }

    public static ResultMsgUtil getMsg() {
        ResultMsgUtil msg = new ResultMsgUtil();
        return msg;
    }

    public static ResultMsgUtil getFailedMsg(String result) {
        ResultMsgUtil msg = new ResultMsgUtil();
        msg.setResult("FAILED");
        msg.setResultMsg(result);
        return msg;
    }

    public static ResultMsgUtil getMapMsg(Object data) {
        ResultMsgUtil msg = new ResultMsgUtil();
        Map<String, Object> map = new HashMap<>();
        map.put("data", data);
        msg.setData(data);
        msg.setResultCode(0);
        return msg;
    }

    public static ResultMsgUtil getMsg(Object data) {
        ResultMsgUtil msg = new ResultMsgUtil();
        msg.setData(data);
        return msg;
    }
}
